{% extends "ads/base.html" %}

{% load i18n %}

{% block title %}{{ ad.title }} | {% trans "Ad Home" %} | {{ block.super }}{% endblock %}

{% block h1 %}{% trans "Ad Home" %}{% endblock %}

{% block body %}

<div class="clear_both">
    <div class="box orange al_center">
        <a href="edit/">{% trans "Edit" %}</a>
    </div>

    <div class="box blue al_center">
        <a href="delete/">{% trans "Delete" %}</a>
    </div>

    <div class="box olive panel">
        <table class="form">
            <tr>
                <th>{% trans "Ad Title" %}</th>
                <td>{{ ad.title }}</td>
            </tr>
            <tr>
                <th>{% trans "Advertiser" %}</th>
                <td><a href="{{ advertiser.get_absolute_url }}">{{ advertiser }}</a></td>
            </tr>
            <tr>
                <th>{% trans "Ad Code" %}</th>
                <td>{{ ad.id }}</td>
            </tr>
        </table>
    </div>
</div>

<div class="box silver clear_both" style="text-align:center">
    <h2>{% trans "Informations" %}</h2>

    <ul class="info">
        <li>{% trans "Viewed" %}: {{ ad.view_count }}</li>
        <li>{% trans "Clicked" %}: {{ ad.click_count }}</li>
        <li>{% trans "Last view" %}: {{ ad.last_view|date:"Y-m-d H:i:s" }}</li>
        <li>{% trans "Next view" %}: {{ ad.next_view|date:"Y-m-d H:i:s" }}</li>
    </ul>
</div>

{% if ad.log_entries.count %}
<div class="box silver clear_both" style="text-align:center">
    <h2>{% trans "Latest 30 day" %}</h2>

    <div class="chart">
        {{ chart_latest30days|safe }}
    </div>
</div>

<div class="box silver clear_both" style="text-align:center">
    <h2>{% trans "Days of month" %}</h2>

    <div class="chart">
        {{ chart_days_of_month|safe }}
    </div>
</div>

<div class="box silver clear_both" style="text-align:center">
    <h2>{% trans "Days of week" %}</h2>

    <div class="chart">
        {{ chart_days_of_week|safe }}
    </div>
</div>

<div class="box silver clear_both" style="text-align:center">
    <h2>{% trans "Months" %}</h2>

    <div class="chart">
        {{ chart_months|safe }}
    </div>
</div>

<div class="box silver clear_both" style="text-align:center">
    <h2>{% trans "Hours" %}</h2>

    <div class="chart">
        {{ chart_hours|safe }}
    </div>
</div>

<div class="box silver clear_both" style="text-align:center">
    <h2>{% trans "Latest 10 log entries" %}</h2>

    <table class="list">
        <tr>
            <th>{% trans "When" %}</th>
            <th>{% trans "URL" %}</th>
            <th>{% trans "Type" %}</th>
        </tr>
        {% for log in ad.log_entries.all|slice:":10" %}
        <tr>
            <td>{{ log.date|timesince }}</td>
            <td>{{ log.url }}</td>
            <td>{{ log.get_type_display }}</td>
        </tr>
        {% endfor %}
    </table>
</div>
{% endif %}

{% endblock body %}

